package com.example.onlinereadingsystem.demos.web.controller;

import com.example.onlinereadingsystem.demos.web.util.AliOSSUtils;
import com.example.onlinereadingsystem.demos.web.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description 普通控制类
 * @Author ljm
 * @Date 2024/10/17
 */
@RestController
@RequestMapping("/common")
public class CommonController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public Result<String> upload(String fileName, MultipartFile file) throws Exception {
        String url = aliOSSUtils.upload(file, fileName);
        return Result.OK(url);
    }
}
